"""
title:商品搜索页面
author:陈诚
date:2022/1/6
"""
# 引入模块
from Common.Base import Base, open_browser

# 网址
login_url = 'http://localhost:8080/ecshop/'


class GoodsSearchPage(Base):
    """封装表现层:制作定位器的过程"""
    keyword_loc = ('name', 'keywords')     # 定位输入框
    button_loc = ('name', 'imageField')    # 定位搜索按钮

    """封装操作层:针对表现层中的元素进行操作"""
    def input_keyword(self, keyword: str):
        """
        输入关键字
        :param keyword: 关键字
        :return:
        """
        self.send_keys(self.keyword_loc, keyword)

    def click_search(self):
        """
        点击搜素按钮
        :return:
        """
        self.click(self.button_loc)


if __name__ == '__main__':
    search = GoodsSearchPage(open_browser())
    search.open_url(login_url)
    search.input_keyword('手机')
    search.click_search()
